package container.set;

import java.util.Set;
import java.util.TreeSet;

public class TreeSet1
{
    public static void main (String[] args)
    {
        //在TreeSet中给定比较器对象
        Set<Student> students = new TreeSet<>(new StudentComparator());
        
        Student student1 = new Student("oldlu", 18);
        Student student2 = new Student("stx", 22);
        Student student3 = new Student("chen", 22);
        
        students.add(student1);
        students.add(student2);
        students.add(student3);
        
        for(Student temp: students)
        {
            System.out.println(temp);
        }
        
    }
}

